package h0708;

import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class TestCaseExecutePlan {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        //
        int featureNum = sc.nextInt();
        int caseNum=sc.nextInt();

        //优先级大的用例先执行，如果存在优先级相同的用例，用例 ID 小的先执行。
        int[] features=new int[featureNum];
        for (int i = 0; i < featureNum; i++) {
            features[i]= sc.nextInt();
        }
        sc.nextLine();
        Integer[][] cases=new Integer[caseNum][2];
        for (int i = 0; i < cases.length; i++) {
            String s = sc.nextLine();
            int[] temp = Arrays.stream(s.split(" ")).mapToInt(Integer::parseInt).toArray();
            int sum = Arrays.stream(temp).sum();
            cases[i][0]=sum;
            //记录当前下标
            cases[i][1]=i+1;
        }
        Arrays.sort(cases, new Comparator<Integer[]>() {
            @Override
            public int compare(Integer[] o1, Integer[] o2) {
                int sumComparison = Integer.compare(o2[0], o1[0]);
                if (sumComparison!=0){
                    return sumComparison;
                }else {
                    return Integer.compare(o1[1],o2[1]);
                }
            }
        });
        for (int i = 0; i < cases.length; i++) {
            System.out.println(cases[i][1]);
        }
    }
}
